# -*- coding: utf-8 -*-
########################################################################
#   Pax-Selector. Copyright 2010, Hector Sanjuán.                      #
#                                                                      #
#   Pax-selector is free software: you can redistribute it and/or      #
#   modify it under the terms of the GNU General Public License as     #
#   published by the Free Software Foundation, either version 3 of     #
#   the License, or any later version.                                 #
#                                                                      #
#   Pax-selector is distributed in the hope that it will be useful,    #
#   but WITHOUT ANY WARRANTY; without even the implied warranty of     #
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      #
#   GNU General Public License for more details.                       #
#                                                                      #
#   You should have received a copy of the GNU General Public License. #
#   If not, see <http://www.gnu.org/licenses/>.                        #
#                                                                      #
########################################################################

class PaxSelector
  module Views
    class Info < Mustache
      def participant
        @indiv.delete(:checkedCondemn)
        @indiv.delete(:checked1)
        @indiv.delete(:checked2)
        @indiv.delete(:checked3)
        @indiv.delete(:checkedIndult)

        case @mark
        when "condemn"
          @indiv[:checkedCondemn]=%&checked="checked"&
        when "1"
          @indiv[:checked1]=%&checked="checked"&
        when "2"
          @indiv[:checked2]=%&checked="checked"&
        when "3"
          @indiv[:checked3]=%&checked="checked"&
        when "indult"
          @indiv[:checkedIndult]=%&checked="checked"&
        else
          # very ugly fix when the symbol values stays from
          # other user session
          # TODO find another way of placing this in.
          @indiv.each do | key, value |
            @indiv.delete(key) if key.to_s.include?("checked")
          end
        end
        
        fields=""
        @list.fields.each do |field|
			fields +="<tr>
				<td id=\"fieldname\">#{field}</td>
				<td id=\"fieldcontent\">#{@indiv[field]}</td>
				</tr>\n" if @indiv[field]
        end
        @indiv[:fields] = fields
        @indiv[:comment] = @comment
        return @indiv
      end
    end
  end
end
